﻿

        var valueArray = [];
        function displayData() {

            setButtons();
            var positionName = "";
            var arrayPosition = 0;
            var startP = 0;
            var endP = 0;
            var content = "";
            content += '<table  cellpadding="5" cellspacing="5" width="200" border="0"><caption style="background-color:#97b92c;color:white;">Event Planning Website</caption>'

            if (window.localStorage) {
                var key, value, field;
                // loop through local storage  
                for (var i = 0; i < localStorage.length; i++) {
                    // retrieve the key           
                    key = localStorage.key(i);
                    value = unescape(localStorage.getItem(key));
                    // set the field from the key      
                    endP = key.indexOf(":");
                    positionName = key.substring(startP, endP);
                    arrayPosition = key.substring(endP + 1, key.length);

                    if (positionName == 'venues' || positionName == 'printshop' || positionName == 'meal_delivery') {
                        valueArray = value.split("|");
                        var pName = "";
                        if (positionName == "venues") {
                            pName = "Venue :: ";
                        }
                        else if (positionName == "printshop") {
                            pName = "Printing :: ";
                        }
                        else {
                            pName = "Caterer :: ";
                        }
                        content += '<tr><td nowrap="true"  align="center">' + pName + '' + '</td>';
                        //content += '<td  nowrap><img class="placeIcon" src="' + valueArray[0] + '"/></td>';
                        content += '<td   nowrap>'+ valueArray[2] + '</b></td>';
                        content += '<td  nowrap><b><img  src="images/map.jpg" style="width:25;height:25;cursor:pointer;" onclick="openURl(1,' + i + ')"/></td></tr>'

                    }
                   

                }   // end for loop   
            }   // end local storage check }
            else {
                content += '<tr><td nowrap="true"  align="center">No Data Found</td></tr>';
                       
            }
            content += '</table>';
            document.getElementById("mydform").innerHTML = content;

           
        }
        function openURl(p, lsid) {
            var value, key, urlArray;
            key = localStorage.key(lsid);
            value = unescape(localStorage.getItem(key));
            // set the field from the key      
            urlArray = value.split("|");
           window.open(urlArray[p]);

        }

        function changeFrameSrc(url) {
            document.getElementById('asideframe').src = url;
            }
        function FrameSrc(url) {
           window.parent.changeFrameSrc(url);


        }
        // start button for listener
        var btnStartPlanning;
        function initGetStarted() {
            // set the button event handler for on click
            btnStartPlanning = document.getElementById('sPlanning');
            btnStartPlanning.addEventListener('click', function () {
                var zip = document.getElementById('zipcode').value;
                if (zip == "") { alert("Please enter a Zip Code to get started"); return; };
                if (typeof (Storage) !== "undefined") {
                    //set the item
                    sessionStorage.setItem("zipcode", zip);

                }
                else {
                    alert(" No! localStorage and sessionStorage supported!")
                }

                FrameSrc('PlacesSearch.html');
            }, false);
        }

        var btnPrint;
        var btnStartOver;

        function setButtons() {
            btnPrint = document.getElementById('Print');
            btnPrint.addEventListener('click', printData, false);

            btnStartOver = document.getElementById('StartOver');
            btnStartOver.addEventListener('click', sentToHomePage, false);
        }

        function printData() {

            btnPrint.display = 'none';
            btnStartOver.display = 'none';
            window.print();
            // btnPrint.display = 'inline';
            //btnStartOver.display = 'inline';

        }

        function sentToHomePage() {
            window.parent.location.reload();
        }
        window.addEventListener('load', initGetStarted, false);
        window.addEventListener('load', displayData, false);

